package com.hhit.zhgd.service.impl

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
import com.hhit.zhgd.dao.ZhgdCronJobMapper
import com.hhit.zhgd.domain.entity.ZhgdCronJob
import com.hhit.zhgd.service.ZhgdCronJobService
import org.springframework.stereotype.Service

@Service("zhgdCronJobService")
class ZhgdCronJobServiceImpl : ZhgdCronJobService, ServiceImpl<ZhgdCronJobMapper, ZhgdCronJob>() {
    override fun getCronExpressionForTask(taskName: String): String? {
        val queryWrapper = QueryWrapper<ZhgdCronJob>()
        queryWrapper.eq("cron_expression",taskName)
        queryWrapper.last("limit 1")
        val one = this.getOne(queryWrapper)
        if (one == null) {
            throw java.lang.RuntimeException("未找到定时任务:$taskName")
        } else {
            return one.cronExpression
        }
    }

}